package jhunter.dao;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import jhunter.common.id.UuidShorter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class EntityContainer {

	private Log log = LogFactory.getLog(this.getClass());
	
	private Map<String, EntityExt> container = new ConcurrentHashMap<String, EntityExt>();
	
	private UuidShorter uuidShorter;
	
	public UuidShorter getUuidShorter() {
		return uuidShorter;
	}

	public void setUuidShorter(UuidShorter uuidShorter) {
		this.uuidShorter = uuidShorter;
	}

	public synchronized void registEntityExt(EntityExt entity) {
		log.debug("load entity : " + entity.getEntity().getId());
		container.put(entity.getEntity().getId(), entity);
	}

	public synchronized void remove(String entityId) {
		container.remove(entityId);
	}

	public EntityExt getEntityExt(String id) {
		return container.get(id);
	}

	public Map<String, EntityExt> getContainer() {
		return container;
	}

}
